package com.fesine.quartz.chapter4;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.quartz.*;
import org.quartz.impl.StdSchedulerFactory;

import java.math.BigDecimal;
import java.util.Date;

/**
 * @description: JobDataMap使用演示
 * @author: Fesine
 * @createTime:2016/11/19 16:46
 * @update:修改内容
 * @author: Fesine
 * @updateTime:2016/11/19 16:46
 */
public class Listing_4_6 {
    static Log logger = LogFactory.getLog(Listing_4_6.class);

    public static void main(String[] args) {
        Listing_4_6 example = new Listing_4_6();
        example.runScheduler();
    }

    public void runScheduler() {
        Scheduler scheduler = null;
        try {
            scheduler = StdSchedulerFactory.getDefaultScheduler();
            scheduler.start();
            logger.info("scheduler was started at " + new Date());
            JobDetail jobDetail = new JobDetail("PrintJobDataMapJob", Scheduler.DEFAULT_GROUP,
                    PrintJobDataMapJob.class);
            jobDetail.getJobDataMap().put("name", "fesine");
            jobDetail.getJobDataMap().put("age", 30);
            jobDetail.getJobDataMap().put("balance", new BigDecimal(9999));
            Trigger trigger = TriggerUtils.makeImmediateTrigger(0, 10000);
            trigger.setName("PrintJobDataMapJobTrigger");
            scheduler.scheduleJob(jobDetail, trigger);
        } catch (SchedulerException e) {
            e.printStackTrace();
        }
    }
}
